home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2596 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.5 KB

  1. Path: locutus.rchland.ibm.com!usenet
  2. From: pstaite@vnet.ibm.com
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Recursive Definition?
  5. Date: 18 Jan 1996 15:34:07 GMT
  6. Organization: IBM OS/2 Device Driver Development  Rochester, MN
  7. Message-ID: <4dlp9f$lje@locutus.rchland.ibm.com>
  8. References: <4df39j$f80@news.vcd.hp.com> <4dish8$43c@is.bbsrc.ac.uk> <4djo71$bnj@geraldo.cc.utexas.edu>
  9. Reply-To: pstaite@vnet.ibm.com
  10. NNTP-Posting-Host: warpone.rchland.ibm.com
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4djo71$bnj@geraldo.cc.utexas.edu>, Richard Kilgore <rkilgore@lore.ece.utexas.edu> writes:
  14. >Robert Tuck <Robert.Tuck@bbsrc.ac.uk> wrote:
  15. >>[...]
  16. >>>      static const Switch On;
  17. >>>      static const Switch Off;
  18. >>[...]
  19. >>>const Switch Switch::On = 1;
  20. >>>const Switch Switch::Off = 0;
  21.  
  22. ..
  23.  
  24. >On and Off are not exactly members, though, they're STATIC members.  In C++,
  25. >this means that there is ONE "Switch::On" and ONE "Switch::Off" object in the
  26. >whole program (or at least this process).  Whoever did this, might have been
  27. >setting up constants with which you can initialize and/or compare your own
  28. >Switch objects.  This is perfectly legal, and it might be useful.
  29.  
  30. It might be useful, but it doesn't work in this case.  If you look 
  31. closely at the code, the init is calling the Switch( int ) constructor 
  32. to build the statics On and Off.  However, the Switch( int ) constructor
  33. compares the int to Switch::On !!!
  34.  
  35.  
  36. Phil Staite, team OS/2
  37. internet: pstaite@vnet.ibm.com  internal: pstaite@rchland
  38.  
  39.